<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>文章管理</el-breadcrumb-item>
      <el-breadcrumb-item>分类文章</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <!-- 搜索与添加区域 -->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容" clearable>
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
        <el-col :span="4">
          <el-button type="primary">搜索文章</el-button>
        </el-col>
      </el-row>

      <!-- 用户列表区域 -->
      <el-table
        :data="articlelist"
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
        border
        stripe
      >
        <el-table-column type="index"></el-table-column>
        <el-table-column label="文章标题" prop="title"></el-table-column>
        <el-table-column label="文章类别" prop="category"></el-table-column>
        <el-table-column label="添加日期" prop="addTime"></el-table-column>
        <el-table-column label="浏览量" prop="pv"></el-table-column>
        <el-table-column label="操作" width="180px">
          <template :slot-scope="scope">
            <!-- 修改按钮 -->
            <el-button type="primary" icon="el-icon-edit" size="mini"></el-button>
            <!-- 删除按钮 -->
            <el-button type="danger" icon="el-icon-delete" size="mini"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      articlelist: [],
      loading: true
    };
  },
  created() {
    this.getArticle();
  },
  methods: {
    getArticle() {
      this.$axios({
        method: "get",
        url: "/articlesSort"
      }).then(response => {
        console.log(response.data.data);
        response.data.data.forEach((item, index) => {
          setTimeout(() => {
              this.loading = false;
              this.articlelist.push(item);
          }, 2000);
        });
      });
    }
  }
};
</script>